using System.Windows;
using WPFServices.ViewModels.DomainViewModel.ProductPlaninfo;

namespace WPFServices.Views.DomainViews.ProductPlaninfo
{
    /// <summary>
    /// AddProductPlan.xaml 的交互逻辑
    /// </summary>
    public partial class AddProductPlan : Window
    {
        public AddProductPlan()
        {
            InitializeComponent();
            
            var viewModel = new AddProductPlanViewModel();
            DataContext = viewModel;
            
            // 订阅关闭窗口事件
            viewModel.CloseWindow += (result) =>
            {
                try
                {
                    DialogResult = result;
                    Close();
                }
                catch (System.Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine($"关闭窗口时出错: {ex.Message}");
                    Close();
                }
            };
        }
    }
} 